package com.ys.字符串作业题;

/**
 * 描述: TODO
 *
 * @author CodeYang
 * @version 2020/12/22 9:11
 */
public class 获Str得大写小写数字个数 {
    public static void main(String[] args) {
        method1("hello word 520 A");

    }

    /**
     * 获得 str 中 大写,小写,数字的个数
     *
     * @param str
     */
    private static void method1(String str) {
        int sumUp = 0;
        int sumLo = 0;
        int nums = 0;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
                sumUp++;
            } else if (ch >= 'a' && ch <= 'z') {
                sumLo++;
            } else if (ch >= '0' && ch <= '9') {
                nums++;
            }
        }
        System.out.println("大写字母个数"+sumUp);
        System.out.println("小写字母个数"+sumLo);
        System.out.println("数字个数"+nums);
    }
}
